<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>百度换肤</title>
    <style>

        li {
            float:left;
            list-style: none;
        }
        li img{
            width: 200px;
            height: 200px;
            display: block;
            margin: 200px auto;
        }
    </style>
</head>
<body>
<ul>
    <li><img src="images/1.jpg"></li>
    <li><img src="images/2.jpg"></li>
    <li><img src="images/3.jpg"></li>
    <li><img src="images/4.jpg"></li>
</ul>
<script>
    var img=document.querySelector("ul").querySelectorAll("img");
    for(var i=0;i<img.length;i++){
        img[i].onclick=function(){
            document.body.style.backgroundImage="url("+this.src+")";
        }}
</script>
</body>
</html>